package easyapache;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
	public static void startServer(int port) {
		try {
			ServerSocket serverSocket = new ServerSocket(port);
			while (true) {
				Socket socket = serverSocket.accept();
				new RequestHandler(socket).start();
			}
		} catch (IOException e) {
			System.out.println("开启服务端口失败");
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
		int port = 80;
		if (args.length==1) {
			port = Integer.parseInt(args[0]);
		}
		startServer(port);
		
	}

}
